from rest_framework.permissions import BasePermission

from product.models import User

# 自定义权限类，用于保护视图访问
class ProductPermissionAny(BasePermission):
    def has_permission(self, request, view):
        from product.views import ProductView, ProductCategoryView
        if isinstance(view, (ProductView, ProductCategoryView)):
            return True

        return False

    # def has_object_permission(self, request, view, obj):
    #     if isinstance(obj, User):
    #         return False
    #
    #     return True
